<template>
  <swiper>
    <swiper-item v-for="item in banners">
      <a :href="item.link">
        <img :src="item.image" alt="" @load="imgLoad">
      </a>
    </swiper-item>
  </swiper>
</template>

<script>
import {Swiper, SwiperItem} from '@/components/common/swiper'

export default {
  name: "HomeSwiper",
  props: {
    // Home.vue中父传子
    banners: {
      type: Array,
      // 类型是对象或者数组时, 默认值必须是一个函数
      default() {
        return []
      }
    }
  },
  data(){
    return{
      isLoad:true
    }
  },
  components: {
    Swiper,
    SwiperItem
  },
  methods:{
    imgLoad(){
      if (this.isLoad){
        this.$emit('swiperImageLoad')
        this.isLoad = false
      }
    }
  }
}
</script>

<style scoped>

</style>
